package empanadasPtya2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;



public class EmpanadasMetodo {

	public String metodoEmpanadas(String ingredientes) {
	
		boolean invalido2 = true;

		int conv[] = new int[6];
		String cadena = ".*[a-zA-Z].*";
		String valores = "";
		int P = 0;
		int M = 0;
		int C = 0;
		int K = 0;
		int R = 0;
		int V = 0;
		int division1 = 0;
		int division2 = 0;
		int division3 = 0;
		int menor = 0;

		do {

			valores = ingredientes;

			Pattern pat = Pattern.compile(cadena);
			Matcher mat = pat.matcher(valores);

			if (mat.matches()) {
				invalido2 = true;
				return "nose pueden ingresar letras ";
			} else {
				invalido2 = false;
			}

		} while (invalido2 != false);

		String fraseSplit[] = valores.split(" ");

		for (int i = 0; i < 6; i++) {
			conv[i] = Integer.parseInt(fraseSplit[i]);

		}

		if (conv[0] >= 0 && conv[0] <= 10000 && conv[1] >= 0
				&& conv[1] <= 10000 && conv[2] >= 0 && conv[2] <= 10000
				&& conv[3] >= 0 && conv[3] <= 10000 && conv[4] >= 0
				&& conv[4] <= 10000 && conv[5] >= 0 && conv[5] <= 10000) {

			if (conv[0] > 0 && conv[1] > 0 && conv[2] > 0 && conv[3] > 0
					&& conv[4] > 0 && conv[5] > 0) {
				for (int j = 0; j < 3; j++) {
					P = conv[0];
					M = conv[1];
					C = conv[2];
				}
				for (int n = 3; n < 6; n++) {
					K = conv[3];
					R = conv[4];
					V = conv[5];
				}

				division1 = P / K;
				division2 = M / R;
				division3 = C / V;

				if (division1 < division2 && division1 < division3) {
					menor = division1;
				} else if (division2 < division1 && division2 < division3) {
					menor = division2;
				} else if (division3 < division1 && division3 < division2) {
					menor = division3;
				}

			}

		} 
		return "puede hacer " + menor + " empanadas";

	}

}
